[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
     defined(EXPR)

     defined EXPR

             Returns a boolean value saying  whether  the  lvalue
             EXPR  has  a  real  value  or  not.  Many operations
             return the undefined value under exceptional  condi-
             tions,  such as end of file, uninitialized variable,
             system error and such.  This function allows you  to
             distinguish  between  an undefined null string and a
             defined  null  string  with  operations  that  might
             return a real null string, in particular referencing
             elements of an array.  You may also check to see  if
             arrays  or  subroutines  exist.   Use  on predefined
             variables is not  guaranteed  to  produce  intuitive
             results.  Examples:

                  print if defined $switch{'D'};
                  print "$val\n" while defined($val = pop(@ary));
                  die "Can't readlink $sym: $!"
                       unless defined($value = readlink $sym);
                  eval '@foo = ()' if defined(@foo);
                  die "No XYZ package defined" unless defined %_XYZ;
                  sub foo { defined &bar ? &bar(@_) : die "No bar"; }

See Also: undef
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson